/**
*      author: Y_Yao
*      created: 2024-11-03 10:41:31
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
string s;

void solve()
{
    cin >> s;
    int count = 0;
    for(int j = 0;j < s.size();j++)
    {
        if(j <= s.size() - 4)
        {
            if(s.substr(j,4) == "1100")
            {
                count++;
            }
        }
    }

    int q;
    cin >> q;
    while(q--)
    {
        int i,v;
        cin >> i >> v;
        for(int j = i - 1;j >= i - 4;j--)
        {
            if(j >= 0 && s.substr(j,4) == "1100")
            {
                count--;
            }
        }

        s[i-1] = v + '0';
        for(int j = i - 1;j >= i - 4;j--)
        {
            if(j >= 0 && s.substr(j,4) == "1100")
            {
                count++;
            }
        }

        if(count > 0)
        {
            cout << "YES" << endl;
        }
        else cout << "NO" << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}